package com.bzframework.example.xxljob;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author bingzhong
 * @Date 2025/9/29
 */
@Slf4j
@Component
public class XxlJobExecutor {


    @XxlJob("demoJob")
    public void demoJob() {
        log.info("demoJob executed");
        XxlJobHelper.log("demoJob executed by log");
    }

    @XxlJob("shardJob")
    public void shardJob() {
        int shardIndex = XxlJobHelper.getShardIndex();
        int shardTotal = XxlJobHelper.getShardTotal();
        log.info("shardJob executed; shardIndex:{},shardTotal:{}", shardIndex, shardTotal);
    }


}
